home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97a.txt / 000115_icon-group-sender _Mon Apr 14 17:25:04 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Received: from kingfisher.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Mon, 14 Apr 1997 12:43:27 MST
  2. Received: by kingfisher.CS.Arizona.EDU; (5.65v3.2/1.1.8.2/08Nov94-0446PM)
  3.     id AA03699; Mon, 14 Apr 1997 12:43:27 -0700
  4. To: icon-group@cs.arizona.edu
  5. Date: 14 Apr 1997 17:25:04 GMT
  6. From: eddie@tattoo.ed.ac.uk (Eddie Corns)
  7. Message-Id: <5itp9g$4l5@scotsman.ed.ac.uk>
  8. Organization: Edinburgh University
  9. Sender: icon-group-request@cs.arizona.edu
  10. References: <Stuart.Robinson-1204971710220001@asianstmg-203.anu.edu.au>
  11. Subject: Re: More on Records
  12. Errors-To: icon-group-errors@cs.arizona.edu
  13. Status: RO
  14. Content-Length: 1561
  15.  
  16. Stuart.Robinson@anu.edu.au (Stuart Robinson) writes:
  17.  
  18.  
  19. >Suppose you want to scan through each line of a text looking for a
  20. >particular type of word.  Roughly speaking, the first time you find it, it
  21. >should go to one field of a record and the second time you find it, it
  22. >should go to another field of the same record.  (The word will appear at
  23. >most two times in a line, possibly not at all.)  How would you do it?
  24.  
  25. I wouldn't.  I would just use a list, they're wonderful things.
  26.  
  27. >More concretely, if you have the following line
  28.  
  29. >{T.p istam eCel 3{O stuK 1{A
  30.  
  31. I would probably try decrytping it!
  32.  
  33. >and a record with four fields like the following
  34.  
  35. >record[index1, arg1, index2, arg2]
  36.  
  37. >how do you write code that would take the first word with "{" followed by
  38. >"S", "A", or "O" and put it into arg1 and its accompanying number into
  39. >index1 and then take the second word in the same line with "{" followed by
  40. >"S", "A", or "O" and put it into arg2 and its accompanying number into
  41. >index2, as below?
  42.  
  43. >record[3, {O, 1, {A]
  44.  
  45. Well, assuming a split function to return an array of items:
  46.  
  47. rec := []
  48. x := split(line)
  49. every i := 1 to *x do x[i] ?
  50.     if tab(find("{")+1) & =("A"|"S"|"O") then put(rec,i) & put(rec,x[i])
  51.  
  52. (Hmmm that's a bit clumsy, can I do =!"ASO" - can't be bothered typing it in
  53. again to try it)
  54. This creates a list of found items rather than a record.  I'm not sure if put()
  55. works on records, if not and you really want to use a record you'd just need a
  56. counter to keep track (since you _can_ address elements of a record by
  57. position).
  58.  
  59. Eddie
  60.